<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" lang="zh-CN">

<div th:fragment="content">
    <p class="text-muted">过滤条件</p>

    <div class="form-group">
        <div class="row">
            <div class="col-md-4">
                <label class="col-sm-3 control-label text-right">组合</label>
                <div class="col-sm-9">
                    <select id="conditionOperation" class="form-control select-control">
                        <option th:each="o,s:${condition?.operation}" th:value="${o?.name}" th:text="${o?.name}" />
                    </select>
                </div>
            </div>
            <div class="col-md-4">
                <label class="col-sm-3 control-label text-right">数据源表字段</label>
                <div class="col-sm-9">
                    <select id="conditionSourceField" class="form-control select-control">
                        <!-- 数据源表公共字段 -->
                        <option th:if="${tableGroup} == null" th:each="c,s:${mapping?.sourceColumn}" th:value="${c?.name}" th:text="${c?.name} +' (' + ${c?.typeName} +')'" />

                        <!-- 数据源表字段 -->
                        <option th:each="c,s:${tableGroup?.sourceTable?.column}" th:value="${c?.name}" th:text="${c?.name} +' (' + ${c?.typeName} +')'" />
                    </select>
                </div>
            </div>
            <div class="col-md-4">
                <label class="col-sm-3 control-label text-right">条件</label>
                <div class="col-sm-9">
                    <select id="conditionFilter" class="form-control select-control">
                        <option th:each="f,s:${condition?.filter}" th:value="${f?.name}" th:text="${f?.name}" />
                    </select>
                </div>
            </div>
        </div>
    </div>

    <div class="form-group">
        <div class="row">
            <div class="col-md-4">
                <label class="col-sm-3 control-label text-right">参数</label>

                <div class="col-sm-9">
                    <textarea id="conditionArg" class="form-control" rows="2" placeholder="请输入参数"></textarea>
                </div>
            </div>
            <div class="col-md-4">
                <label class="col-sm-3 control-label text-right">系统参数</label>

                <div class="col-sm-9">
                    <div class="dropdown">
                        <button type="button" th:title="（仅适用于增量同步）" class="btn btn-default dropdown-toggle" id="conditionDropdown" data-toggle="dropdown">
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" role="menu" aria-labelledby="conditionDropdown">
                            <li role="presentation" th:each="f,s:${condition?.quartzFilter}" >
                                <a role="menuitem" class="conditionQuartzFilter" tabindex="-1" th:text="${f?.type}" th:title="${f?.message}" href="javascript:;"></a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="col-md-3"></div>
            <div class="col-md-1">
                <button id="conditionAdd" type="button" class="btn btn-primary">
                    <span class="fa fa-plus"></span>添加
                </button>
            </div>
        </div>
    </div>

    <div class="form-group">
        <div class="row">
            <div class="col-md-1"></div>
            <div class="col-md-11">
                <table id="conditionTable" class="table table-hover hidden">
                    <thead>
                        <tr>
                            <th>组合</th>
                            <th>数据源表字段</th>
                            <th>条件</th>
                            <th>参数</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody id="conditionList">
                        <!-- Mapping convert -->
                        <tr th:if="${tableGroup} == null" th:each="f,s:${mapping?.filter}">
                            <td>[[${f?.operation}]]</td>
                            <td>[[${f?.name}]]</td>
                            <td>[[${f?.filter}]]</td>
                            <td>[[${f?.value}]]</td>
                            <td><a class='fa fa-remove fa-2x conditionDelete dbsyncer_pointer' title='删除' ></a></td>
                        </tr>
                        <!-- TableGroup convert -->
                        <tr th:each="f,s:${tableGroup?.filter}">
                            <td>[[${f?.operation}]]</td>
                            <td>[[${f?.name}]]</td>
                            <td>[[${f?.filter}]]</td>
                            <td>[[${f?.value}]]</td>
                            <td><a class='fa fa-remove fa-2x conditionDelete dbsyncer_pointer' title='删除' ></a></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <!-- 隐藏表单值 -->
    <div class="form-group hidden">
        <input id="filter" name="filter" class="form-control" type="text"/>
    </div>

</div>
</html>